/**
 * 生成唯一ID的工具类
 */
export class UniqueIdGenerator {
    private static _counter: number = 0;
    private static _prefix: string = 'UID_';

    /**
     * 生成一个唯一的ID
     * @param prefix 可选前缀
     * @returns 唯一ID字符串
     */
    public static generate(prefix?: string): string {
        const timestamp = Date.now().toString(36);
        const random = Math.random().toString(36).substring(2, 8);
        const counter = (this._counter++).toString(36);
        const prefixToUse = prefix || this._prefix;
        return `${prefixToUse}${timestamp}_${random}_${counter}`;
    }

    /**
     * 生成简单的唯一ID（递增数字）
     * @returns 递增的数字ID
     */
    public static generateSimple(): string {
        return `ID_${this._counter++}`;
    }

    /**
     * 生成基于时间戳的唯一ID
     * @returns 时间戳ID
     */
    public static generateTimestamp(): string {
        return `TID_${Date.now()}_${Math.floor(Math.random() * 10000)}`;
    }
}